home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 2 / Apprentice-Release2.iso / Source Code / Libraries / SAT 2.3a1 / myPlatform ƒ / myPlatform.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-22  |  2.5 KB  |  105 lines  |  [TEXT/KAHL]

  1. #include "SAT.h"
  2.  
  3. /**************/
  4. /* myPlatform demo*/
  5. /**************/
  6.  
  7. /* This demo is a hack I made, testing if we can use faceless sprites to make stationary*/
  8. /* obstacles. That worked pretty nicely, so I went on and made some moving platforms too.*/
  9. /* Take it for what it is: a test hack that suggests one way to make this kind of games.*/
  10. /* There are many other ways. The controls can be improved a lot, but it is a start.*/
  11.  
  12. /* Translated to C by Mike Zimmerman */
  13.  
  14. #include "myPlatform.h"
  15.  
  16. SATPatHandle    thepat;
  17. long             L;
  18. SpritePtr        ignoreSp;
  19. Point            p;
  20.  
  21. void DrawInfo()
  22. {
  23.     Rect    r;
  24.     
  25.     SetPort(gSAT.backScreen);
  26.     SetRect(&r, 100, 50, 300, 100);
  27.     EraseRect(&r);
  28.     FrameRect(&r);
  29.     MoveTo(110, 70);
  30.     DrawString("\pSAT Platform demo");
  31.     MoveTo(110, 90);
  32.     DrawString("\pMove with , . and space");
  33.     SATBackChanged(&r);
  34. }
  35.  
  36.  
  37. main()
  38. {
  39.     Rect        tempRect;
  40.  
  41.     MaxApplZone ();
  42.     FlushEvents (everyEvent - diskMask, 0 );
  43.     InitGraf (&thePort);
  44.     InitFonts ();
  45.     InitWindows ();
  46.     InitMenus ();
  47.     TEInit ();
  48.     InitDialogs (nil);        /* no restart proc */
  49.     InitCursor ();
  50.  
  51.     MoreMasters ();
  52.     MoreMasters ();
  53.  
  54.  
  55. /* End of initializations */
  56.  
  57.     SATConfigure(true, kLayerSort, kBackwardCollision, 32);
  58.     SATInit(0, 0, 512, 322);  /* No PICTs */
  59.  
  60.     /* Use a background pattern (instead of PICTs - just to demo that too) */
  61.     
  62.     SetPort(gSAT.backScreen);  
  63.     thepat = SATGetPat(128);
  64.     SATPenPat(thepat);
  65.     SetRect(&tempRect, 0, 0, gSAT.offSizeH, gSAT.offSizeV);
  66.     PaintRect(&tempRect);
  67.     
  68.     CopyBits(&(gSAT.backScreen)->portBits, &gSAT.offScreen->portBits, &gSAT.offScreen->portRect, &gSAT.offScreen->portRect, srcCopy, nil);
  69.  
  70.     DrawInfo();
  71.     
  72. /*Initialize all sprite units*/
  73.     InitPlayerSprite();
  74.     InitPlatform();
  75.     InitMovPlatform();
  76.     InitHMovPlatform();
  77.     
  78. /*Update the game window once more, so the pattern and what we drawn in DrawInfo are shown. */
  79.     SATRedraw();
  80.     
  81.     SetRect(&tempRect, 0, 0, gSAT.offSizeH, gSAT.offSizeV);
  82.       CopyBits(&(gSAT.offScreen->portBits), &(gSAT.wind->portBits), &tempRect, &tempRect, srcCopy, nil);
  83.  
  84.     GetMouse(&p);
  85.     ignoreSp = SATNewSprite(1, p.h, p.v, &SetupPlayerSprite);
  86.     ignoreSp = SATNewSprite(0, 50, 300, &SetupPlatform);
  87.     ignoreSp = SATNewSprite(0, 150, 200, &SetupPlatform);
  88.     ignoreSp = SATNewSprite(0, 250, 100, &SetupPlatform);
  89.     ignoreSp = SATNewSprite(0, 350, 50, &SetupPlatform);
  90.     ignoreSp = SATNewSprite(0, 350, 300, &SetupMovPlatform);
  91.     ignoreSp = SATNewSprite(0, 50, 200, &SetupMovPlatform);
  92.     ignoreSp = SATNewSprite(0, 200, 150, &SetupHMovPlatform);
  93.  
  94.     HideCursor();
  95.     while (!Button())
  96.     {
  97.         L = TickCount();
  98.         SATRun(true);
  99.         while (L > TickCount() - 2L)
  100.             ;
  101.     }
  102.     ShowCursor();
  103.     SATSoundShutup();
  104. }
  105.